package tp3_ex3;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
public class TestRot {
	/* Methode principal qui permet de tester la class Rot13OutputStream, selon le nombre d'argument */
	public static void main (String[] argv)
	{
		switch(argv.length)
		{
		case 0 :
			Rot13OutputStream cesar1 = new Rot13OutputStream();
			cesar1.write();
			break;

		case 1 :
			File in = new File(argv[0]);
			Rot13OutputStream cesar2 = new Rot13OutputStream(in);
			cesar2.write();
			break;

		case 2 :
			File in2 = new File(argv[0]);
			File out = new File(argv[1]);
			BufferedOutputStream buffOut = null;
			try 
			{
				buffOut = new BufferedOutputStream(new FileOutputStream(out));
			} catch (IOException e) {
				e.printStackTrace();
			}
			Rot13OutputStream cesar3 = new Rot13OutputStream(in2,buffOut);
			try {
				cesar3.write();
				buffOut.close();
			}catch (FileNotFoundException e) {
				e.printStackTrace();}
			catch (IOException e) {
				e.printStackTrace();
			}
			break;
		default : 
			System.out.println("Nombre de variable incoherent !\nFin du programme");
			break;
		}
	}
}
